Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get true dimensions for image metadata #17264

Closed
wants to merge 5 commits into from
Closed

Conversation

jfsoul
Copy link
Contributor

@jfsoul jfsoul commented Jun 26, 2017

What does this change?

Image metadata dimensions were based on the base image asset dimensions, but really should have been the true image dimensions that we actually serve after resizing. Tidy up after #17258

What is the value of this and can you measure success?

Image metadata dimensions are accurate. I don't know whether this has much effect, because I'm not sure how much these numbers are used by search engines etc.

Does this affect other platforms - Amp, Apps, etc?

Yes

Screenshots

Tested in CODE?

No

import views.support.Item700

object Image {

def apply(picture: ImageElement): JsValue = {
val asset: Option[ImageAsset] = Item700.bestFor(picture.images)
val url = Item700.bestSrcFor(picture.images).getOrElse("")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

had to define these here to make the compiler happy 😨

@PRBuilds
Copy link

PRbuilds results:

Screenshots
desktop.pngtablet.pngmobile.pngwide.png

Exceptions (0)
thrown-exceptions.js

A11y validation (0)
a11y-report.txt

Apache Benchmark Load Testing
loadtesting.txt

--automated message

@jfsoul
Copy link
Contributor Author

jfsoul commented Jun 26, 2017

Actually it looks like I need to take the minimum of the original asset dimension and the (attempted) resize by imgix. Imgix won't resize to any larger than the original dimensions as far as I can tell. cc: @paperboyo does that sound right?

@paperboyo
Copy link
Contributor

Imgix won't resize to any larger than the original dimensions as far as I can tell

Yep, that’s right (fit=max added here). Nor should it (quality wouldn’t be any better, filesize adversely affected)!

@jfsoul
Copy link
Contributor Author

jfsoul commented Jun 26, 2017

Thanks for people's time looking at this for me, but I'm taking the pragmatic decision and leaving this unchanged for now. I've fixed up the logic to be closer to the true behaviour, but until someone can prove this metadata actually affects anything I don't want to introduce this unnecessary complexity to the codebase.

N.B. I still don't think my most recent attempt is quite right because it assumes fit=max resizing is always width-driven, when height could instead the constraining factor.

@jfsoul jfsoul closed this Jun 26, 2017
@jfsoul jfsoul deleted the jfs-img-true-width-meta branch June 26, 2017 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants